import type { FormRules } from "naive-ui";
import {
    ROOM_CAPACITY_RAGE_MAX,
    ROOM_CAPACITY_RAGE_MIN,
    ROOM_NAME_PATTERN,
    ROOM_PASSWORD_PATTERN
} from "@/pages/room/constant/validation-constants.ts";

export default {
    "name": [
        {
            required: true,
            message: "名称必须设置"
        },
        {
            pattern: ROOM_NAME_PATTERN,
            message: "2~15位的字母、数字、中文"
        }
    ],
    "password": [
        {
            validator: (rule, value) => {
                if (value) {
                    return ROOM_PASSWORD_PATTERN.test(value);
                }
                return true;
            },
            message: "3~16位的字母、数字、下划线、小数点"
        }
    ],
    "capacity": [
        {
            validator: (rule, value) => {
                return value >= ROOM_CAPACITY_RAGE_MIN && value <= ROOM_CAPACITY_RAGE_MAX;
            },
            message: `只能在${ROOM_CAPACITY_RAGE_MIN}~${ROOM_CAPACITY_RAGE_MAX}之间`
        }
    ]
} as FormRules